package com.yy.permissions_general.module.system.roleAuth.vo;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName AuthVo
 * @Description: TODO 权限vo
 * @Author YangYI
 * @Date 2021/9/29
 * @Version V1.0
 **/
@Data
public class RoleAuthVo implements Serializable {
    private static final long serialVersionUID = 1L;
    private Integer id;
    private Integer pId;
    private String label;
    private Boolean disabled;
    private Boolean checked;
    private Boolean radioDisabled;
    private Boolean isOpen;
    private Boolean isLeaf;
    private List<RoleAuthVo> children;

    /**
     * 递归
     * @param id 当前权限ID
     * @param list 权限列表
     * @return
     */
    public static List<RoleAuthVo> roleAuthVoUtil(Integer id, List<RoleAuthVo> list){
        List<RoleAuthVo> trees = new ArrayList();
        for (RoleAuthVo menuVo : list) {
            if (menuVo.getPId()== id){
                menuVo.setChildren(roleAuthVoUtil(menuVo.getId(),list));
                trees.add(menuVo);
            }
        }
        return trees;
    }
}
